Skip to content

Commit

Permalink
Merge pull request #186 from TelefonicaED/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
virginiama89 authored May 18, 2021
2 parents ce270fb + 020c8ab commit e9bb06f
Show file tree
Hide file tree
Showing 16 changed files with 1,042 additions and 118 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ Todos los cambios de este proyecto estarán documentados en este archivo.

El formato está basado en [SemVer](https://semver.org/spec/v2.0.0.html).


## [4.6.0](https://github.com/TelefonicaED/liferaylms-portlet/releases/tag/v4.6.0)

### Added

- #188000: Añadida nueva etiqueta del nombre de pila del usuario en los mailings del mensaje bienvenida y de baja de cursos
- #191542: Al duplicar una edición o curso hay que configurar las fechas de ejecucion además de las de inscripción
- #198292: Añadida la posibilidad de ordenar las ediciones de un curso

### Updated
Expand Down Expand Up @@ -35,7 +36,6 @@ El formato está basado en [SemVer](https://semver.org/spec/v2.0.0.html).

- Cambios en el registry de las actividades para mejorar rendimiento, establecidas las variables a estáticas para evitar que se lean en cada acceso.


## [4.5.0](https://github.com/TelefonicaED/liferaylms-portlet/releases/tag/v4.5.0)

### Fixed
Expand Down
4 changes: 1 addition & 3 deletions docroot/WEB-INF/liferay-plugin-package.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name=liferaylms-portlet
module-group-id=com.ted.wemooc


module-incremental-version=4.6.0

module-incremental-version=4.7.0

tags=
short-description=
Expand Down
2 changes: 1 addition & 1 deletion docroot/WEB-INF/liferay-portlet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
<configuration-action-class>com.liferay.portal.kernel.portlet.DefaultConfigurationAction</configuration-action-class>
<action-url-redirect>true</action-url-redirect>
<instanceable>false</instanceable>
<header-portlet-css>/css/main.css</header-portlet-css>
<header-portlet-css>/css/inscriptioncommunity.css</header-portlet-css>
<footer-portlet-javascript>/js/main.js</footer-portlet-javascript>
<css-class-wrapper>inscriptioncommunity-portlet</css-class-wrapper>
</portlet>
Expand Down
20 changes: 14 additions & 6 deletions docroot/WEB-INF/src/com/liferay/lms/CloneCourse.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public class CloneCourse extends CourseCopyUtil implements MessageListener {

Date startDate;
Date endDate;
Date startExecutionDate;
Date endExecutionDate;

boolean visible;
boolean includeTeacher;
Expand All @@ -116,6 +118,8 @@ public CloneCourse(long groupId, String newCourseName, ThemeDisplay themeDisplay
this.themeDisplay = themeDisplay;
this.startDate = startDate;
this.endDate = endDate;
this.startExecutionDate = startExecutionDate;
this.endExecutionDate = endExecutionDate;
this.cloneForum = cloneForum;
this.cloneDocuments = cloneDocuments;
this.cloneModuleClassification = cloneModuleClassification;
Expand Down Expand Up @@ -145,6 +149,8 @@ public void receive(Message message) throws MessageListenerException {
this.newCourseName = message.getString("newCourseName");
this.startDate = (Date)message.get("startDate");
this.endDate = (Date)message.get("endDate");
this.startExecutionDate = (Date) message.get("startExecutionDate");
this.endExecutionDate = (Date) message.get("endExecutionDate");
this.serviceContext = (ServiceContext)message.get("serviceContext");
this.themeDisplay = (ThemeDisplay)message.get("themeDisplay");
this.visible = message.getBoolean("visible");
Expand Down Expand Up @@ -232,8 +238,10 @@ public void doCloneCourse() throws Exception {
newCourse.setGoodbyeMsg(course.getGoodbyeMsg());
newCourse.setGoodbyeSubject(course.getGoodbyeSubject());
newCourse.setCourseEvalId(course.getCourseEvalId());
newCourse.setExecutionStartDate(startDate);
newCourse.setExecutionEndDate(endDate);
newCourse.setStartDate(startDate);
newCourse.setEndDate(endDate);
newCourse.setExecutionStartDate(startExecutionDate);
newCourse.setExecutionEndDate(endExecutionDate);

StringBuilder extraContent = new StringBuilder();

Expand Down Expand Up @@ -401,8 +409,8 @@ public void doCloneCourse() throws Exception {

newModule.setAllowedTime(module.getAllowedTime());
newModule.setIcon(module.getIcon());
newModule.setStartDate(startDate);
newModule.setEndDate(endDate);
newModule.setStartDate(startExecutionDate);
newModule.setEndDate(endExecutionDate);
newModule = ModuleLocalServiceUtil.addmodule(newModule);

correlationModules.put(module.getModuleId(), newModule.getModuleId());
Expand Down Expand Up @@ -471,8 +479,8 @@ public void doCloneCourse() throws Exception {
newLearnActivity.setGroupId(newModule.getGroupId());
newLearnActivity.setModuleId(newModule.getModuleId());

newLearnActivity.setStartdate(startDate);
newLearnActivity.setEnddate(endDate);
newLearnActivity.setStartdate(startExecutionDate);
newLearnActivity.setEnddate(endExecutionDate);

if(Validator.isNotNull(activity.getDescription())) {
newLearnActivity.setDescription(descriptionFilesClone(activity.getDescription(),newModule.getGroupId(), newLearnActivity.getActId(),themeDisplay.getUserId()));
Expand Down
192 changes: 191 additions & 1 deletion docroot/WEB-INF/src/com/liferay/lms/CourseAdmin.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.Time;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.kernel.workflow.WorkflowConstants;
Expand Down Expand Up @@ -642,6 +643,141 @@ private void showViewClone(RenderRequest renderRequest,RenderResponse renderResp

ThemeDisplay themeDisplay = (ThemeDisplay)renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

TimeZone timeZone = themeDisplay.getTimeZone();

long groupId = ParamUtil.getLong(renderRequest, "groupId", 0);

try{
Group groupObj = GroupLocalServiceUtil.getGroup(groupId);
Course course = CourseLocalServiceUtil.getCourseByGroupCreatedId(groupId);

boolean isCourseChild = false;
String courseTitle = "course";
if(course!=null){
if(course.getParentCourseId()>0){
isCourseChild=true;
}

courseTitle = course.getTitle(themeDisplay.getLocale());
String newCourseName = groupObj.getName()+"_"+Time.getShortTimestamp();
renderRequest.setAttribute("isCourseChild", isCourseChild);
renderRequest.setAttribute("courseTitle", courseTitle);
renderRequest.setAttribute("groupId", groupId);
renderRequest.setAttribute("newCourseName", newCourseName);

String[] layusprsel=null;
if(renderRequest.getPreferences().getValue("courseTemplates", null)!=null&&renderRequest.getPreferences().getValue("courseTemplates", null).length()>0)
{
layusprsel=renderRequest.getPreferences().getValue("courseTemplates", "").split(",");
}
String[] lspList=LmsPrefsLocalServiceUtil.getLmsPrefsIni(themeDisplay.getCompanyId()).getLmsTemplates().split(",");
if(layusprsel!=null && layusprsel.length>0)
{
lspList=layusprsel;
}

if(lspList.length>1){
List<LayoutSetPrototype> prototypeList = new ArrayList<LayoutSetPrototype>();
for(String lspId: lspList){
prototypeList.add(LayoutSetPrototypeLocalServiceUtil.getLayoutSetPrototype(Long.parseLong(lspId)));
}

renderRequest.setAttribute("lspList", prototypeList);
renderRequest.setAttribute("viewTemplateSelector", true);
}else{
LayoutSetPrototype lsp=LayoutSetPrototypeLocalServiceUtil.getLayoutSetPrototype(Long.parseLong(lspList[0]));
renderRequest.setAttribute("lspId", lsp.getLayoutSetPrototypeId());
renderRequest.setAttribute("viewTemplateSelector", false);
}


SimpleDateFormat formatDay = new SimpleDateFormat("dd");
formatDay.setTimeZone(timeZone);
SimpleDateFormat formatMonth = new SimpleDateFormat("MM");
formatMonth.setTimeZone(timeZone);
SimpleDateFormat formatYear = new SimpleDateFormat("yyyy");
formatYear.setTimeZone(timeZone);
SimpleDateFormat formatHour = new SimpleDateFormat("HH");
formatHour.setTimeZone(timeZone);
SimpleDateFormat formatMin = new SimpleDateFormat("mm");
formatMin.setTimeZone(timeZone);
Date today=course.getStartDate();
if(Validator.isNull(today)){
today = new Date();
}
int startDay=Integer.parseInt(formatDay.format(today));
int startMonth=Integer.parseInt(formatMonth.format(today))-1;
int startYear=Integer.parseInt(formatYear.format(today));
int startHour=Integer.parseInt(formatHour.format(today));
int startMin=Integer.parseInt(formatMin.format(today));

today = course.getEndDate();
if(Validator.isNull(today)){
today = new Date();
}

int endDay=Integer.parseInt(formatDay.format(today));
int endMonth=Integer.parseInt(formatMonth.format(today))-1;
int endYear=Integer.parseInt(formatYear.format(today));
int endHour=Integer.parseInt(formatHour.format(today));
int endMin=Integer.parseInt(formatMin.format(today));
//Inscription Date
renderRequest.setAttribute("startDay", startDay);
renderRequest.setAttribute("startMonth", startMonth);
renderRequest.setAttribute("startYear", startYear);
renderRequest.setAttribute("startHour", startHour);
renderRequest.setAttribute("startMin", startMin);
renderRequest.setAttribute("defaultStartYear", LiferaylmsUtil.defaultStartYear);
renderRequest.setAttribute("defaultEndYear", LiferaylmsUtil.defaultEndYear);
renderRequest.setAttribute("endDay", endDay);
renderRequest.setAttribute("endMonth", endMonth);
renderRequest.setAttribute("endYear", endYear);
renderRequest.setAttribute("endHour", endHour);
renderRequest.setAttribute("endMin", endMin);


today = course.getExecutionStartDate();

if(Validator.isNull(today)){
today = new Date();
}
startDay=Integer.parseInt(formatDay.format(today));
startMonth=Integer.parseInt(formatMonth.format(today))-1;
startYear=Integer.parseInt(formatYear.format(today));
startHour=Integer.parseInt(formatHour.format(today));
startMin=Integer.parseInt(formatMin.format(today));

today = course.getExecutionEndDate();

if(Validator.isNull(today)){
today = new Date();
}
endDay=Integer.parseInt(formatDay.format(today));
endMonth=Integer.parseInt(formatMonth.format(today))-1;
endYear=Integer.parseInt(formatYear.format(today));
endHour=Integer.parseInt(formatHour.format(today));
endMin=Integer.parseInt(formatMin.format(today));

//Execution Date
renderRequest.setAttribute("startExecutionDay", startDay);
renderRequest.setAttribute("startExecutionMonth", startMonth);
renderRequest.setAttribute("startExecutionYear", startYear);
renderRequest.setAttribute("startExecutionHour", startHour);
renderRequest.setAttribute("startExecutionMin", startMin);
renderRequest.setAttribute("defaultStartYear", LiferaylmsUtil.defaultStartYear);
renderRequest.setAttribute("defaultEndYear", LiferaylmsUtil.defaultEndYear);
renderRequest.setAttribute("endExecutionDay", endDay);
renderRequest.setAttribute("endExecutionMonth", endMonth);
renderRequest.setAttribute("endExecutionYear", endYear);
renderRequest.setAttribute("endExecutionHour", endHour);
renderRequest.setAttribute("endExecutionMin", endMin);

}
}catch(Exception e){
e.printStackTrace();
}


include(this.cloneJSP, renderRequest, renderResponse);
}

Expand Down Expand Up @@ -1120,7 +1256,7 @@ public void importCourse(ActionRequest actionRequest, ActionResponse actionRespo
}
}

public void cloneCourse(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
public void cloneCourse(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
ServiceContext serviceContext = ServiceContextFactory.getInstance(Course.class.getName(), actionRequest);
Expand All @@ -1132,6 +1268,8 @@ public void cloneCourse(ActionRequest actionRequest, ActionResponse actionRespon
boolean cloneDocuments = ParamUtil.getBoolean(actionRequest, "cloneDocuments");
boolean cloneModuleClassification = ParamUtil.getBoolean(actionRequest, "cloneModuleClassification");
boolean cloneActivityClassificationTypes = ParamUtil.getBoolean(actionRequest, "cloneActivityClassificationTypes");

/*
int startMonth = ParamUtil.getInteger(actionRequest, "startMon");
int startYear = ParamUtil.getInteger(actionRequest, "startYear");
int startDay = ParamUtil.getInteger(actionRequest, "startDay");
Expand All @@ -1153,6 +1291,54 @@ public void cloneCourse(ActionRequest actionRequest, ActionResponse actionRespon
stopHour += 12;
}
Date endDate = PortalUtil.getDate(stopMonth, stopDay, stopYear, stopHour, stopMinute, themeDisplay.getTimeZone(), EntryDisplayDateException.class);
*/

//Inscription Date
int startMonth = ParamUtil.getInteger(actionRequest, "startMon");
int startYear = ParamUtil.getInteger(actionRequest, "startYear");
int startDay = ParamUtil.getInteger(actionRequest, "startDay");
int startHour = ParamUtil.getInteger(actionRequest, "startHour");
int startMinute = ParamUtil.getInteger(actionRequest, "startMin");
int startAMPM = ParamUtil.getInteger(actionRequest, "startAMPM");
if (startAMPM > 0) {
startHour += 12;
}
Date startDate = PortalUtil.getDate(startMonth, startDay, startYear, startHour, startMinute, themeDisplay.getTimeZone(), EntryDisplayDateException.class);

int stopMonth = ParamUtil.getInteger(actionRequest, "stopMon");
int stopYear = ParamUtil.getInteger(actionRequest, "stopYear");
int stopDay = ParamUtil.getInteger(actionRequest, "stopDay");
int stopHour = ParamUtil.getInteger(actionRequest, "stopHour");
int stopMinute = ParamUtil.getInteger(actionRequest, "stopMin");
int stopAMPM = ParamUtil.getInteger(actionRequest, "stopAMPM");
if (stopAMPM > 0) {
stopHour += 12;
}
Date endDate = PortalUtil.getDate(stopMonth, stopDay, stopYear, stopHour, stopMinute, themeDisplay.getTimeZone(), EntryDisplayDateException.class);

startMonth = ParamUtil.getInteger(actionRequest, "startExecutionMon");
startYear = ParamUtil.getInteger(actionRequest, "startExecutionYear");
startDay = ParamUtil.getInteger(actionRequest, "startExecutionDay");
startHour = ParamUtil.getInteger(actionRequest, "startExecutionHour");
startMinute = ParamUtil.getInteger(actionRequest, "startExecutionMin");
startAMPM = ParamUtil.getInteger(actionRequest, "startExecutionAMPM");
if(startAMPM > 0) {
startHour += 12;
}
Date startExecutionDate = PortalUtil.getDate(startMonth, startDay, startYear, startHour, startMinute, themeDisplay.getTimeZone(), EntryDisplayDateException.class);

stopMonth = ParamUtil.getInteger(actionRequest, "stopExecutionMon");
stopYear = ParamUtil.getInteger(actionRequest, "stopExecutionYear");
stopDay = ParamUtil.getInteger(actionRequest, "stopExecutionDay");
stopHour = ParamUtil.getInteger(actionRequest, "stopExecutionHour");
stopMinute = ParamUtil.getInteger(actionRequest, "stopExecutionMin");
stopAMPM = ParamUtil.getInteger(actionRequest, "stopExecutionAMPM");
if (stopAMPM > 0) {
stopHour += 12;
}
Date endExecutionDate = PortalUtil.getDate(stopMonth, stopDay, stopYear, stopHour, stopMinute, themeDisplay.getTimeZone(), EntryDisplayDateException.class);



//CloneCourseThread cloneThread = new CloneCourseThread(groupId, newCourseName, themeDisplay, startDate, endDate, serviceContext);
//Thread thread = new Thread(cloneThread);
Expand Down Expand Up @@ -1190,8 +1376,12 @@ public void cloneCourse(ActionRequest actionRequest, ActionResponse actionRespon
message.put("groupId",groupId);
message.put("newCourseName",newCourseName);
message.put("themeDisplay",themeDisplay);
/*message.put("startDate",startDate);
message.put("endDate",endDate);*/
message.put("startDate",startDate);
message.put("endDate",endDate);
message.put("startExecutionDate",startExecutionDate);
message.put("endExecutionDate",endExecutionDate);
message.put("serviceContext",serviceContext);
message.put("visible",visible);
message.put("cloneForum", cloneForum);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ else if(course.isDeniedInscription()){
}
String body = StringUtil.replace(
course.getDeniedInscriptionMsg(),
new String[] {"[$FROM_ADDRESS$]", "[$FROM_NAME$]", "[$PAGE_URL$]","[$PORTAL_URL$]","[$TO_ADDRESS$]","[$TO_NAME$]","[$USER_SCREENNAME$]","[$TITLE_COURSE$]"},
new String[] {fromAddress, fromName, urlcourse, url, user.getEmailAddress(), user.getFullName(),user.getScreenName(),course.getTitle(user.getLocale())});
new String[] {"[$FROM_ADDRESS$]", "[$FROM_NAME$]", "[$PAGE_URL$]","[$PORTAL_URL$]","[$TO_ADDRESS$]","[$TO_NAME$]","[$USER_SCREENNAME$]","[$TITLE_COURSE$]","[$TO_FIRSTNAME$]"},
new String[] {fromAddress, fromName, urlcourse, url, user.getEmailAddress(), user.getFullName(),user.getScreenName(),course.getTitle(user.getLocale()), user.getFirstName()});

if(log.isDebugEnabled()){
log.debug(from);
Expand Down
14 changes: 6 additions & 8 deletions docroot/WEB-INF/src/com/liferay/lms/listeners/GroupListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,8 @@ public void onAfterAddAssociation(Object classPK,
if(log.isDebugEnabled())log.debug("preferencia editorRole: " + PrefsPropsUtil.getBoolean(course.getCompanyId(), LmsConstant.SEND_MAIL_TO_EDITORS, true));

//Si no es tutor o editor, es alumno, así que creamos el courseresult
if(!tutorRole && !editorRole){
if(CourseResultLocalServiceUtil.getCourseResultByCourseAndUser(course.getCourseId(), userId) == null) {
CourseResultLocalServiceUtil.addCourseResult(PrincipalThreadLocal.getUserId(), course.getCourseId(), userId);
}
if(CourseResultLocalServiceUtil.getCourseResultByCourseAndUser(course.getCourseId(), userId) == null) {
CourseResultLocalServiceUtil.addCourseResult(PrincipalThreadLocal.getUserId(), course.getCourseId(), userId);
}

if(course!=null&&course.isWelcome()&&course.getWelcomeMsg()!=null&&!StringPool.BLANK.equals(course.getWelcomeMsg())){
Expand Down Expand Up @@ -157,8 +155,8 @@ public void onAfterAddAssociation(Object classPK,

String body = StringUtil.replace(
course.getWelcomeMsg(),
new String[] {"[$FROM_ADDRESS$]", "[$FROM_NAME$]", "[$PAGE_URL$]","[$PORTAL_URL$]","[$TO_ADDRESS$]","[$TO_NAME$]","[$USER_SCREENNAME$]","[$TITLE_COURSE$]","[$ROLE$]"},
new String[] {fromAddress, fromName, urlcourse, url, user.getEmailAddress(), user.getFullName(),user.getScreenName(),course.getTitle(user.getLocale()), userRole});
new String[] {"[$FROM_ADDRESS$]", "[$FROM_NAME$]", "[$PAGE_URL$]","[$PORTAL_URL$]","[$TO_ADDRESS$]","[$TO_NAME$]","[$USER_SCREENNAME$]","[$TITLE_COURSE$]","[$ROLE$]","[$TO_FIRSTNAME$]"},
new String[] {fromAddress, fromName, urlcourse, url, user.getEmailAddress(), user.getFullName(),user.getScreenName(),course.getTitle(user.getLocale()), userRole, user.getFirstName()});

if(log.isDebugEnabled()){
log.debug(from);
Expand Down Expand Up @@ -409,8 +407,8 @@ public void onAfterRemoveAssociation(Object classPK,

String body = StringUtil.replace(
course.getGoodbyeMsg(),
new String[] {"[$FROM_ADDRESS$]", "[$FROM_NAME$]", "[$PAGE_URL$]","[$PORTAL_URL$]","[$TO_ADDRESS$]","[$TO_NAME$]","[$USER_SCREENNAME$]","[$TITLE_COURSE$]","[$ROLE$]"},
new String[] {fromAddress, fromName, urlcourse, url, user.getEmailAddress(), user.getFullName(),user.getScreenName(),course.getTitle(user.getLocale()), userRole});
new String[] {"[$FROM_ADDRESS$]", "[$FROM_NAME$]", "[$PAGE_URL$]","[$PORTAL_URL$]","[$TO_ADDRESS$]","[$TO_NAME$]","[$USER_SCREENNAME$]","[$TITLE_COURSE$]","[$ROLE$]","[$TO_FIRSTNAME$]"},
new String[] {fromAddress, fromName, urlcourse, url, user.getEmailAddress(), user.getFullName(),user.getScreenName(),course.getTitle(user.getLocale()), userRole, user.getFirstName()});


if(log.isDebugEnabled()){
Expand Down
2 changes: 1 addition & 1 deletion docroot/WEB-INF/src/content/Language_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ correction-body-mail = Hallo {0},<br /><br /> Ihre Arbeit wurde bewertet.<br /><

correction-subject-mail = 3. Bewertung erhalten

course-admin.friendlyurl = URL
course-admin.friendlyurl = URL

course-correction-method = Bewertungsmethode

Expand Down
Loading

0 comments on commit e9bb06f

Please sign in to comment.