[Building Sakai] Assignment2: Getting userid associated with an attachment

David Wafula davidwaf at gmail.com
Tue Nov 13 02:35:20 PST 2012


I think i found a way to this:

                Assignment2 assign = assignmentLogic.getAssignmentById(id);
                //lets get all the submissioins in here
                Set<AssignmentSubmission> assignmentSubmissions =
assign.getSubmissionsSet();

                //then look into each of these for submissions

                for (AssignmentSubmission assignmentSubmission :
assignmentSubmissions) {
                    Set<AssignmentSubmissionVersion>
assignmentSubmissionVersions =
assignmentSubmission.getSubmissionHistorySet();
                    for (AssignmentSubmissionVersion
assignmentSubmissionVersion : assignmentSubmissionVersions) {
                        if (assignmentSubmissionVersion.isSubmitted()) {
                            //then get the attachments on this submission
                            String studentId =
assignmentSubmissionVersion.getCreatedBy();
                            String[] attachRefs =
assignmentSubmissionVersion.getSubmittedAttachmentRefs();

                        }
                    }
                }

OR
 "select ATTACHMENT_REFERENCE,subver.CREATED_BY "
                + " from A2_SUBMISSION_T sub,A2_SUBMISSION_VERSION_T
subver, A2_SUBMISSION_ATTACH_T subatt "
                + " where sub.SUBMISSION_ID=subver.SUBMISSION_ID and "
                + "
subver.SUBMISSION_VERSION_ID=subatt.SUBMISSION_VERSION_ID and
sub.assignment_id=" + assignId;

Regards..


On Tue, Nov 13, 2012 at 10:14 AM, David Wafula <davidwaf at gmail.com> wrote:

> hi all,
> Any pointers here...the SQL stmt in my earlier post above is not returning
> accurate results...i mean, when i run it, the attachment_reference is all
> wrong.
>
> Thanks.
>
>
> On Sun, Nov 11, 2012 at 4:56 PM, David Wafula <davidwaf at gmail.com> wrote:
>
>> Hello all,
>> I couldn't figure out how to find a user who submitted an attachment,
>> when all i have is an assignmentId.
>>
>> Assignment2 assign = assignmentLogic.getAssignmentById(assignmentId);
>> Using assign.getSubmissionsSet() returns Set<SubmissionAttachment>,
>> SubmissionAttachment doesn't seem to have any reference to userid.
>>
>> In the end, i went direct into DB:
>>
>> "SELECT ATTACHMENT_REFERENCE,USER_ID "
>>                             + "from A2_SUBMISSION_T
>> subm,A2_SUBMISSION_ATTACH_T attach "
>>                             + "where
>> subm.SUBMISSION_ID=attach.SUBMISSION_ATTACH_ID and ASSIGNMENT_ID="+assignId;
>>
>> Would have preferred to use API .
>>
>> This is assignment2 1.1-SNAPSHOT in Sakai 2.8.0.
>> Thanks
>> --
>> David Wafula
>>
>
>
>
> --
> David Wafula
>



-- 
David Wafula
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20121113/dd554fd1/attachment.html 


More information about the sakai-dev mailing list