Skip to content

Instantly share code, notes, and snippets.

@sammso
Last active June 8, 2018 13:56
Show Gist options
  • Save sammso/641a39fa4bcf9d18a337ab756b89deb6 to your computer and use it in GitHub Desktop.
Save sammso/641a39fa4bcf9d18a337ab756b89deb6 to your computer and use it in GitHub Desktop.

Configuration portlet

https://www.dropbox.com/s/wsspavxno4gesw4/supercoolmvc.zip?dl=0

Clean up LCS

  • Shutdown portal
  • Remove bundles/osgi/marketplace/LCS .. Client.lpkg
  • Remove all files and folders from bundles/osgi/state/
  • Remove all files and folders from bundles/tomcat.../work/
  • Remove all files and folders from bundles/tomcat.../temp/
  • Start the portal

Localization example

https://www.dropbox.com/s/evixdjui91yv6ud/localization-example-web.zip?dl=0

Complete and refactored

  • This applicaiton is refactored and is using instead of ResourceBlockPermissions it is using ResourcePermission

https://www.dropbox.com/s/md1n4vplwqh64ze/gradebook.zip?dl=0

  • Add blow to SubmissionLocalServiceImpl (run servicebuilder) and expose that to SubmissionServiceImpl (run servicebuilder)
	public Submission addSubmission(long assignmentId, long studentId, int grade, String comment, ServiceContext serviceContext ) throws PortalException {
		System.err.println("xxx");
		long submissionId =
			counterLocalService.increment(Submission.class.getName());

		Assignment assignment = assignmentPersistence.findByPrimaryKey(assignmentId);
		
		Submission submission = createSubmission(submissionId);
		submission.setAssignmentId(assignmentId);
		submission.setSubmissionId(submissionId);
		submission.setCompanyId(assignment.getCompanyId());
		submission.setGroupId(assignment.getGroupId());
		submission.setStudentId(studentId);
		submission.setCreateDate(new Date());
		submission.setModifiedDate(new Date());
		submission.setGrade(grade);
		submission.setComment(comment);

		return super.addSubmission(submission);
	}

For later

  • Add Assignment:
Liferay.Service('/space.assignment/add-assignment', {
	groupId: 20143,
	userId: 31043,
	title: { 'en_US': 'How to make birhday cake'},
	description: 'Design most delicious and beautifull birthday cake. Serve that to who deserves it.',
	dueDate: (new Date('2018-05-22')).getTime()
}, function(obj) {
	console.log(obj);
});
  • List Assignments
Liferay.Service('/space.assignment/get-assignments-by-group-id', {
	groupId: 20143,
	start: -1,
	end: -1
},
function(obj) {
	console.log(obj);
});
  • Add submission
Liferay.Service(
  '/space.submission/add-submission',
  {
	assignmentId: 301,
	studentId: 31022 ,
	grade: 5,
	comment: 'Cheesecake with straberries and blueberries'
  },
  function(obj) {
    console.log(obj);
  }
);
  • Combine these to one remote call.
Liferay.Service({'$assignment = /space.assignment/add-assignment':{
		groupId: 20143,
		userId: 31043,
		title: { 'en_US': 'Please, make birhday cake'},
		description: 'Design most delicious and beautifull birthday cake. Serve that to who deserves it.',
		dueDate: (new Date('2018-05-22')).getTime(),
		'$submission = /space.submission/add-submission': {
			'@assignmentId': '$assignment.assignmentId',
			studentId: 31022 ,
			grade: 5,
			comment: 'Cheesecake with straberries and blueberries'
		}
	}
}, 
function(obj) {
	console.log(obj);
});
  • Below is not working, but you can take it as also example.
Liferay.Service({
	'$company[companyId] = /company/get-company-by-virtual-host' : {
		virtualHost: 'localhost',
		'$group[groupId] = /group/get-company-group': {
			'@companyId': '$company.companyId',
			'$student[userId] = /user/get-user-by-screen-name':{
				'@companyId': '$company.companyId',
				screenName: 'test',
				'$assignment = /gradebook.assignment/add-assignment': {
					'@groupId': '$group.groupId',
					titleMap: { 'en_US': 'How to make birhday cake'},
					description: 'Design most delicious and beautifull birthday cake. Serve that to who deserves it.',
					dueDate: (new Date('2018-05-22')).getTime(),
					'$submission = /gradebook.submission/add-submission': {
						'@assignmentId': '$assignment.assignmentId',
						'@studentId': '$student.userId',
						submissionText: 'Cheesecake with straberries and blueberries'
					}
				}
			}
	  }
	}
}, function(obj) {
		console.log(obj);
});

Frontend developer

To add Gradebook at theme

<#--
<@liferay_portlet["runtime"] 
portletName="com_liferay_training_space_gradebook_portlet_GradebookPortlet"
/>

To display Gradebook Assignment as Asset

  • classPK is assignmentId
<@liferay_ui["asset-display"]
className="com.liferay.training.space.gradebook.model.Assignment"
classPK=1
template="full_content"
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment