Forum LAMS for Tech-Heads - General Forum: LAMS 2.0 - Share Resources - Add Single File


 
You may request notification for LAMS 2.0 - Share Resources - Add Single File.
Search: 

1: LAMS 2.0 - Share Resources - Add Single File
01/31/07 03:56 AM
[ Reply | Forward ]
Hi all,

I'm a bit confused (probably unnecessarily) as to what the 'Add Single File' option of Share Resources is actually doing with the selected file. Normally, and elsewhere in LAMS 2.0, when you Browse... a file, you click Upload and it is transferred to the server. However, with 'Add Single File', it forces you to Browse and then you fill in the rest of the form and you're done.... there doesn't appear to be an uploading at all.

The reason this came to light is because one of my colleagues authored a sequence, shared some images and then got the following error message on the Share Resources page when he launched the sequence with a test student account:

Your current role does not allow you to view this page. Please contact your system administrator if you believe you should be given have access.

???403.message???

I've since tried to locate the file on the server but can't seem to find it. So - does the image/file actually get uploaded or are we missing something obvious this end?

Many thanks,

Kris

P.S. I'm going to leave someone else point out the grammatical error in the quoted error message above. I'm not doing it.

Posted by Kristian Besley

2: Re: LAMS 2.0 - Share Resources - Add Single File
In response to 1 02/01/07 06:52 AM
[ Reply | Forward ]
Kris,

The file is uploaded when you click the "Add Single File" button (not the link, the button on the very bottom of the screen). It all happens through the magic of AJAX I think.

Now where the file is stored is tricky. It is stored in the content repository. On Windows this is normally C:\lams\repository\. But you won't find it under the name that it was called when you uploaded it. All the files in the content repository are stored using a numeric id.

I suspect that the lack of file isn't the problem. If the file was just missing on disk, you will get an error more like:

" Sorry, there as been an error.

There is a problem processing this request. Close the browser window and try again. If the problem persists please contact your system administrator or the technical forums on http://lamscommunity.org/.
javax.servlet.ServletException: Unable to read file for uuid 4 versionId 1 due to an IOException. Generated path was C:/lams/repository\04\1:C:\lams\repository\04\1 (The system cannot find the file specified) Show detail "

I think the error is more likely to be related to the user's role. As each tool is its own web-app, it also has its own security settings. Given that the error you get is a security/role error, I think there may be a bug there. I've tried a few "likely" combinations but I haven't been able to reproduce the problem.

Could you run the following sql against your database, replacing "mmm" with the login name of the user who had the problem?

SELECT u.login login, o.NAME group, r.NAME role
FROM lams_user u,
lams_user_organisation uo,
lams_user_organisation_role uor,
lams_organisation o,
lams_role r
WHERE u.login = "mmm"
AND u.user_id = uo.user_id
AND uo.user_organisation_id = uor.user_organisation_id
AND uor.role_id = r.role_id
AND uo.organisation_id = o.organisation_id


You should get results like this. As you can see, "mmm" has LEARNER role in all its groups. Could you post the results, along with with group for which the sequence was running?

mmm    Playpen        AUTHOR
mmm    Playpen        MONITOR
mmm    Playpen        LEARNER
mmm    Everybody    MONITOR
mmm    Everybody    LEARNER
mmm    Mathematics 1    AUTHOR
mmm    Mathematics 1    MONITOR
mmm    Mathematics 1    LEARNER
mmm    Tutorial Group A    MONITOR
mmm    Tutorial Group A    LEARNER

Now as for the grammar, I've changed the message to:

"Your current role does not allow you to view this page. Please contact your system administrator if you believe you should have be given access to this page."

Is that good enough? It is 10:31 PM at night and its a bit late to check with Mum. She always corrected my grammar back in my schooldays and is much more reliable than most computerised grammar checkers. <grin>

Fiona

Posted by Fiona Malikoff

4: Re: Re: LAMS 2.0 - Share Resources - Add Single File
In response to 2 02/01/07 08:27 AM
[ Reply | Forward ]
Hi Fiona,

Thanks for the reply. The results from the query you gave me are thus:

+-------+---------------+---------+
| stu2 | PGCE Students | LEARNER |
| stu2 | LAMS Group | LEARNER |
+-------+---------------+---------+

I didn't set up the user personally, but the user is only intended to be a 'learner' as it is obviously a student. The author who came across the problem had 'author', 'learner' and 'monitor' status too.

Does this help at all? Oh, and as for your 2nd request:

'...along with with group for which the sequence was running?'

Do you just want a copy paste of the group structure from LAMS?

Thanks,

Kris

Posted by Kristian Besley

6: Re: Re: Re: LAMS 2.0 - Share Resources - Add Single File
In response to 4 02/01/07 05:30 PM
[ Reply | Forward ]
I thought I might have put the 2nd request badly, but I couldn't think of another way to put it.

I meant, was the sequence/lesson being run as PGCE Students or LAMS Group or some other group. ie which heading does it appear under on the My Groups page.

Fiona

Posted by Fiona Malikoff

9: Re: Re: Re: Re: LAMS 2.0 - Share Resources - Add Single File
In response to 6 02/02/07 05:19 AM
[ Reply | Forward ]
The group is PGCE Students and the class is LAMS Group.

The lesson is running as 'LAMS Group'. I didn't name it thus by the way!

Posted by Kristian Besley

Attachments:
3: Re: LAMS 2.0 - Share Resources - Add Single File
In response to 1 02/01/07 06:55 AM
[ Reply | Forward ]
Kris,

If you are a glutton for punishment and really want to find the file then.....

One of these days, we intend to add a nice admin screen that lists all the files in the content repository. But for the moment, you have to go searching in the database tables to find out the id number of the file and then you can find it on disk.

Go into your database client and run the following SQL.

SELECT p.nv_id, p.VALUE
FROM lams_cr_workspace w,
    lams_cr_node n,
    lams_cr_node_version v,
    lams_cr_node_version_property p
WHERE w.NAME="sharedresourcesworkspace"
AND w.workspace_id = n.workspace_id
AND n.node_id = v.node_id
AND p.nv_id = v.nv_id
AND p.NAME="FILENAME"


Have a look at the output and see if you can spot the file, based on the filename.

Now take the nv_id value. The number gets split into pairs and the directory name in the content repository is based on the pairs.  So if the nv_id is 5, then look for <repository directory>/05. If the nv_id is 105, then look for <repository directory>/01/05. If the nv_id is 1105, then look for <repository directory>/11/05.

Once you have found the directory, there should be a file in it called "1". This should be the uploaded file. Copy this file to somewhere else, rename it so it has its proper extension and try opening it. It is not zipped or encrypted - just renamed to a number when it is saved on disk.

So, is the file there?

Fiona

Posted by Fiona Malikoff

5: Re: Re: LAMS 2.0 - Share Resources - Add Single File
In response to 3 02/01/07 08:50 AM
[ Reply | Forward ]
I took that challenge and made it work. The AJAX magic must be working because the files are there. I can seem them all with their generic naming system in-place. They long for an identity again.

Which database client are you using btw? Your first query wouldn't run for me. It didn't like some of the aliasing.

Anyway - thanks for this. At least we know that the upload is secretly working...

Thanks,

Kris

Posted by Kristian Besley

7: Re: Re: Re: LAMS 2.0 - Share Resources - Add Single File
In response to 5 02/01/07 05:36 PM
[ Reply | Forward ]
Which client do I use? Well, I use a number of clients, but that particular bit of code was written in DBManager (http://www.dbtools.com.br/).

Sorry about the problem with the aliases. Our scripts get run in the mysql command line client normally to make sure that they are okay with a client that everyone uses. But I just threw that code together last night and forgot to run it in mysql command line client.

Fiona

Posted by Fiona Malikoff

8: Re: Re: Re: Re: LAMS 2.0 - Share Resources - Add Single File
In response to 7 02/02/07 04:29 AM
[ Reply | Forward ]
I've tracked down the problem and it is a bug.

The problem isn't related to the group - it is related to the privileges of the user. It will only show up for a user that has only the LEARNER privilege in all groups - give the user a different role in another group and it won't happen.

I have raised the problem as https://bugs.lamsfoundation.org/browse/LDEV-1136, and it will be fixed in the LAMS 2.0.1 release.

This is the fix, should you care to do it manually. You need to be familiar with the format of Java's .jar and .war files  to try this - if you get it wrong LAMS won't start.

* Shutdown LAMS / JBOSS.
* Go to the lams.ear directory in jboss.
* Copy the lams-tool-larsrc11.war to somewhere else as a backup, in case you don't make the change correctly and need to rollback the change.
* Unzip lams-tool-larsrc11.war to a temporary directory.
* Edit the file WEB-INF\web.xml.
* Find the entry for "Download Files" and change it to this:
    <security-constraint>
          <web-resource-collection>
            <web-resource-name>Download Files</web-resource-name>
            <url-pattern>/download/</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>LEARNER</role-name>
            <role-name>AUTHOR</role-name>
            <role-name>MONITOR</role-name>
            <role-name>TEACHER</role-name>
            <role-name>ADMIN</role-name>
            <role-name>SYSADMIN</role-name>
            <role-name>AUTHOR ADMIN</role-name>
        </auth-constraint>
    </security-constraint>

You will need to add the line <role-name>LEARNER</role-name>

* Rezip up the directory, calling it lams-tool-larsrc11.war. Make sure you don't accidently get an extra folder in the lams-tool-larsrc11.war file - that will cause an error when JBOSS starts up.
* Start JBOSS/LAMS. The problem should now be fixed.

Fiona

Posted by Fiona Malikoff

10: Re: Re: Re: Re: Re: LAMS 2.0 - Share Resources - Add Single File
In response to 8 02/02/07 08:05 AM
[ Reply | Forward ]
Hi Fiona,

Okay, I did this and it now works fine. Thanks very much for the help.

I did actually mess up a couple of times trying to work out how Windows actually zips things. This caused the Share Resources tool to not work at all obviously. I had to restart LAMS a couple of times or three...

(I foolishly couldn't zip a bunch of files without putting them in a containing folder, so in the end I reverted to my Mac safety harness...)

I should have my own separate forum. I don't really belong in Tech-heads. Haha.

Cheers,

Kris

Posted by Kristian Besley

Reply to first post on this page
Back to LAMS for Tech-Heads - General Forum