Hinweis: Sie sind auf den Seiten der Moodle 3.2 Dokumentation. Die Dokumentation der aktuellsten Moodle-Version finden Sie hier: Universal Office Konverter.

Universal Office Konverter

Aus MoodleDocs
Wechseln zu:Navigation, Suche

Neu
in Moodle 3.2!

Was ist unoconv?

Das Kommandozeilenprogramm unoconv wird verwendet, um Office-Dokumente in verschiedene Dateiformate zu konvertieren. Das Programm verwendet zur Konvertierung LibreOffice. Die Konvertierung wird bei Aufgabenabgaben genutzt, um hochgeladene Dateien in PDFs zu konvertieren, in denen Bewerter/innen Annotationen hinterlegen können. Sollte auf dem Moodle-Server kein unoconv installiert sein, dann können Bewerter/innen nur dann Annotationen in Aufgabenabgaben hinterlegen, wenn die hochgeladenen Dateien bereits PDFs sind.

Die Installationsschritte hängen vom Betriebssystem des Moodle-Servers ab.

Installation unter Linux

Sie benötigen unoconv mindestens in der Version 0.7. Abhängig von Ihrer Linus-Distribution ist das Programm über den Paketmanager verfügbar oder kann direkt installiert werden:

Ubuntu 16.04 LTS

apt-get install unoconv

Wenn Ihr Paketmanager eine ältere Version enthält, müssen Sie nach der erforderlichen neuen Version suchen und diese manuell installieren (Debian Testing). Unoconv selbst ist ein Python-Skript, d.h. es hat verschiedene Abhängigkeiten.

Mögliche Probleme:

  • Auf manchen Systemen ist das Homeverzeichnis des Apache-Nutzers als ein Verzeichnis definiert, das gar nicht existiert. Das kann dazu führen, dass unoconv nicht funktioniert. Dann gibt es zwei Lösungsmöglichkeiten: Entweder legen Sie ein schreibbares Homeverzeichnis für den Apache-Nutzer an (z.B. /home/www-data) oder Sie lassen einen unoconv Listener (siehe unten) unter einem anderen Nutzer als dem Apache-Nutzer laufen, und dieser andere Nutzer muss ein schreibbares Homeverzeichnis haben.
  • Wenn Sie noch 14.04LTS laufen haben, wird unoconv nicht wie erwartet arbeiten. In diesem Fall können Sie folgendermaßen vorgehen: Installieren Sie unoconv in der Version 0.6 wie oben beschrieben über den Paketmanager. Ziehen Sie dann unoconv in der Version 0.7 vom Github (https://github.com/dagwieers/unoconv). Aktualisieren Sie auf die aktuellste LibreOffice-Version mit Hilfe von PPA (https://launchpad.net/~libreoffice/+archive/ubuntu/ppa). Verweisen Sie Moodle auf die Github-Version von unoconv. Sie müssen dazu die Python-Datei von unoconv modifizieren, indem Sie in der 1. Zeile python durch python3 ersetzen. Außerdem müssen Sie die Rechte für das Verzeichnis /var/www so ändern, dass der Apache-Nutzer www-data dort schreiben kann.

Unter Debian Stable ist es die sauberste Lösung, unoconv mit Hilfe der Jessie-Backports zu installieren. Als erstes aktivieren Sie die Backports Repo Zeile in /etc/apt/sources.list:

#### Jessie-Backports  ####
deb http://ftp.debian.org/debian jessie-backports main

Anschließend aktualisieren und installieren Sie unoconv von den Jessie-Backports:

apt-get update
apt-get install -t jessie-backports unoconv

Das Paket wird mit allen benötigten Abhängigkeiten ausgeliefert.


Ubuntu 14.04 LTS

1) Navigate to opt directory

cd /opt

2) Download unoconv

sudo wget https://raw.githubusercontent.com/dagwieers/unoconv/master/unoconv

3) Modify the Python unoconv file by changing 'python' in the first line to 'python3'

sudo nano /opt/unoconv


eg.

#!/usr/bin/env python3

4) Make unoconv executable

sudo chmod ugo+x /opt/unoconv

5) Add LibreOffice PPA to your system and install the latest version

sudo add-apt-repository ppa:libreoffice/ppa
sudo apt-get update
sudo apt-get install libreoffice

6) Change permissions so apache can write to its home directory

sudo chown www-data /var/www

7) From your browser navigate to Site administration > Server > System paths and add the path to unoconv
/opt/unoconv

  • Note: if you would like to preserve the default path add a symbolic link to /usr/bin:
sudo ln -s /opt/unoconv /usr/bin/

8) Navigate to Site administration > Plugins > Activity modules > Assignment > Feedback plugins > Annotate PDF > Test unoconv path
You should see:
"The unoconv path appears to be properly configured."

  • Download the converted pdf test file. (if the PDF fails to load ensure that www-data can write to its home directory: /var/www)

CentOS / RedHat

Just before you start, you might like to consider installing the latest LibreOffice 5.2 directly from RPM packages, that are not part of the distribution you are using. As of nov-2016, CentOS and RedHat 7.2 comes with OpenOffice 4.3 . so if you are not interested in using this version and would like to install latest 5.2 independent LibreOffice 5.2 , please remove any openoffice packages you might have on your OS by issuing:

yum remove openoffice* libreoffice*

And then follow the install instructions LibreOffice 5.2. It is recommended to chose your localized libreoffice version for better document conversions. and also please skip the following "yum install openoffice* ..." command.

yum install openoffice* openoffice-pyuno
git clone https://github.com/dagwieers/unoconv.git
# copy 
cp unoconv/unoconv /usr/bin
# or link unoconv to /usr/bin
ln -s unoconv/unoconv /usr/bin/unoconv
Note: depends on what version you are installing, openoffice or libreoffice, make sure you installed the *-pyuno package. (the headless package is already compiled into the core)

Make sure it is properly configured: http://your-moodle/admin/search.php?query=unoconv

Production servers should consider running unoconv in listener mode, see Installing_unoconv#Run_a_unoconv_listener or follow directions bellow

vi /etc/systemd/system/unoconv.service

And then copy and paste the following configuration into it:

[Unit]
Description=Unoconv listener for document conversions
Documentation=https://github.com/dagwieers/unoconv
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=simple
Environment="UNO_PATH=/usr/lib64/libreoffice/program"
ExecStart=/usr/bin/unoconv --listener

[Install]
WantedBy=multi-user.target

And then enable and start the above service

systemctl enable unoconv.service
systemctl start unoconv.service

Installing unoconv on OS X

Download and install LibreOffice for Mac. Unfortunately - newer versions of LibreOffice are not currently compatible with unoconv for mac and you will have to install LibreOffice 4.2 (Direct download link - https://downloadarchive.documentfoundation.org/libreoffice/old/4.2.5.2/mac/x86_64/LibreOffice_4.2.5.2_MacOS_x86-64.dmg).

Get the latest version of the unoconv python script. One way to do this is with http://brew.sh/ brew.

brew install unoconv

If you haven't done it already - install ghostscript. One way to install ghostscript is also with http://brew.sh/ brew

brew install ghostscript

Set the paths to unoconv and ghostscript in Moodle (Site administration > Server > System paths). If you used brew, they will both be installed to /usr/local/bin.

LibreOffice needs write access to the current users home directory to create some temporary files. When unoconv is run as the webserver user (_www) it does not normally have this permission.

There are some ways to get around this - one way is just to give the "_www" user write access to /Library/WebServer.

Another solution is to convince LibreOffice that this users home directory is somewhere else. This can be done by inserting this code into the top of the unoconv python script. Code to insert:

# Set home to a writable folder. 
os.environ['HOME'] = '/tmp/'                                                                                                        

This needs to be inserted at line 36 immediately after the line "exitcode = 0"

Installing unoconv on Windows

Download and install LibreOffice for windows.

Download the latest version of the unoconv script from https://github.com/dagwieers/unoconv/releases (download the zip version).

From the downloaded zip file - extract the one file "unoconv-0.7\unoconv" (no file extension). This is the unoconv script - none of the other files in the package are required.

Rename the downloaded script to C:\unoconv\unoconv.py

Create a batch file C:\unoconv\unoconv.bat with these contents:

@"C:\Program Files\LibreOffice 5\program\python.exe" c:\unoconv\unoconv.py %*

Set paths in Moodle.

Login as admin and go to Site administration > Server > System paths

Set pathtogs setting to your ghostscript installation binary, (C:\gs\bin\gswin32.exe)

Set pathtounoconv to the batch file created above (C:\unoconv\unoconv.bat)

Test ghostscript and unoconv are working correctly in the admin test pages "Site administration > Plugins > Activity modules > Assignment > Feedback plugins > Annotate PDF".

Run a unoconv listener

Unoconv utilises a client/server process when converting documents. By default, when there is no running server process - each time unoconv runs it will start a server process, send its request and shut down the server process when the request is complete. The drawback of this mode is that if 2 requests are submitted simultaneously - this can cause the first request to shutdown the server process when the second request is still in progress - and the second conversion request fails. A more robust way to configure unoconv is to start a server process at boot time, and/or run a script to monitor it and restart it if it crashes.

To start a unoconv listener at boot time - you need a start up script. Different operating systems and Linux distributions use different startup scripts - but here are some examples of startup scripts for different systems.

Upstart script for Ubuntu based systems

Launchd script for OS X

Init script for Debian

Init script for CentOS/RedHat 6.x

SystemD service script for CentOS/RedHat 7.x

Auslagerung der Konvertierung auf einen anderen Server

Die Konvertierung von Dokumenten kann zu einer höheren Last für den Webserver führen und die Geschwindigkeit Ihrer Moodle-Site beeinträchtigen. Bei großen Moodle-Installationen können Sie unoconv auch auf einen anderen Server auslagern.

Wie geht das?

  • Installieren Sie unoconv auf einem beliebigen Webserver (Remote-Server) wie oben beschrieben.
  • Stellen Sie sicher, dass unoconv beim Booten des Remote-Servers gestartet wird.
  • Öffnen Sie den Firewall Port 2002 zwischen dem Moodle-Server und dem Remote-Server.
  • Teilen Sie das Moodle-Datenverzeichnis zwischen dem Moodle-Server und dem Remote-Server. Das Verzeichnis muss auf beiden Servern unter demselben Pfad gemountet werden.
  • Installieren Sie auf dem Moodle-Server einen Wrapper für unoconv, der die Anfragen an den Remote-Server weiterleitet.
Beispiel:
#!/bin/bash
# Wrapper Skript für unoconv zur Weiterleitung von Anfragen.
# Installiert in /usr/bin/unoconv-remote mit 755 Rechten
/usr/bin/unoconv --server=<ip des Remote-Servers> "$@"
  • Konfigurieren Sie in Ihrer Moodle-Site den Pfad zu unoconv so, dass er auf das Wrapper-Skript zeigt.

Weitere Informationen

Weitere Informationen zur Installation und Fehlerbehebung finden Sie auf der unoconc Website.

Siehe auch