Unable to generate exam with exams2moodle when including TikZ picture - tikz

I am trying to generate exams with exams2moodle on my new laptop. Everything worked (and still works) out perfectly fine on my old laptop, but in the new one (where I have exactly the same configuration, but there's obviously something missing), even when I try to run the simplest template with a TikZ figure in R/exams exams2moodle("automaton.Rnw") I get the error message
Error in magick_image_readpath(enc2native(path), density, depth,
strip, : rsession.exe: PDFDelegateFailed `El sistema no puede
encontrar el archivo especificado. ' # error/pdf.c/ReadPDFImage/809
I have checked my installation, and seen the various posts with similar problems, but haven't been able to fix it. Any idea what might be going wrong? Thank you very much in advance
EDIT: That's my session info
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)
Matrix products: default
locale:
[1] LC_COLLATE=Spanish_Spain.1252 LC_CTYPE=Spanish_Spain.1252 LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C
[5] LC_TIME=Spanish_Spain.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] magick_2.4.0 mgsub_1.7.2 ICSNP_1.1-1 ICS_1.3-1 mvtnorm_1.1-1 plotrix_3.7-8
[7] Ryacas_1.1.3 FRACTION_1.0 stringr_1.4.0 Deriv_4.0.1 ggplot2_3.3.2 plot3D_1.3
[13] scatterplot3d_0.3-41 MASS_7.3-53 latex2exp_0.4.0 permute_0.9-5 mpoly_1.1.1 polynom_1.4-0
[19] pracma_2.2.9 numbers_0.7-5 exams_2.3-6
loaded via a namespace (and not attached):
[1] Rcpp_1.0.5 lattice_0.20-41 tidyr_1.1.2 assertthat_0.2.1 rprojroot_1.3-2 digest_0.6.25
[7] gmp_0.6-0 R6_2.4.1 plyr_1.8.6 backports_1.1.10 survey_4.0 evaluate_0.14
[13] pillar_1.4.6 rlang_0.4.7 misc3d_0.9-0 rstudioapi_0.11 Matrix_1.2-18 rmarkdown_2.3
[19] desc_1.2.0 splines_4.0.2 partitions_1.9-22 munsell_0.5.0 tinytex_0.26 compiler_4.0.2
[25] xfun_0.17 pkgconfig_2.0.3 htmltools_0.5.0 tcltk_4.0.2 mitools_2.4 tidyselect_1.1.0
[31] tibble_3.0.3 crayon_1.3.4 dplyr_1.0.2 withr_2.3.0 grid_4.0.2 gtable_0.3.0
[37] lifecycle_0.2.0 DBI_1.1.0 orthopolynom_1.0-5 magrittr_1.5 scales_1.1.1 stringi_1.5.3
[43] testthat_2.3.2 ellipsis_0.3.1 generics_0.0.2 vctrs_0.3.4 tools_4.0.2 glue_1.4.2
[49] purrr_0.3.4 pkgload_1.1.0 survival_3.1-12 colorspace_1.4-1 knitr_1.30

Overview
Thanks for carefully researching the problem and reporting it here. As you already worked out, the problem is not in the code within R/exams directly but with magick::image_read() which does not work correctly in some settings. Thanks also for reporting this to Jeroen Ooms, the magick maintainer.
Bug fix in magick
In response to the issue you filed, Jeroen has updated with the magick package on GitHub with new and updated ImageMagick binaries, see: https://github.com/ropensci/magick/pull/276. Please re-install magick from GitHub which should resolve the problem.
Workaround in exams
A potential workaround that avoids using magick could be to convert the TikZ PDF output to SVG instead of PNG. In that case pdf2svg (and pdfcrop) is needed to be on the PATH (see also the comments for further details). To try it use
exams2html("automaton.Rnw", svg = TRUE)
Or with exams2moodle() instead of exams2html(). (The latter is just easier for quickly inspecting the output.)
Links
Issue in the magick project on GitHub: https://github.com/ropensci/magick/issues/272.
Similar discussion in our R/exams forum on R-Forge: https://R-Forge.R-project.org/forum/forum.php?thread_id=34042&forum_id=4377&group_id=1337.

Related

OpenCobol & PostgreSQL on Windows with Visual Studio

I'm currently facing a problem with this team of 4.
Using binaries I downloaded on kiska's site. I'm able to compile cobol to C and run it with cobcrun or compile it to an executable. However I can 't get opencobol to find the postgres commands.
Here is the strat of my cobol script :
identification division.
program-id. pgcob.
data division.
working-storage section.
01 pgconn usage pointer.
01 pgres usage pointer.
01 resptr usage pointer.
01 resstr pic x(80) based.
01 result usage binary-long.
01 answer pic x(80).
procedure division.
display "Before connect:" pgconn end-display
call "PQconnectdb" using
by reference "dbname = postgres" & x"00"
by reference "host = 10.37.180.146" & "00"
returning pgconn
end-call
...
the call PQconnectdb fail with module ont found : PQconnectdb
I noticed that if i rename the libpq.dll the error message change to can't find entry point. So at least I'm sure it can get my dll.
After digging into the code of the call method of the libcob library. I found it it was possible to pre load some dll using an environment variable COB_PRE_LOAD but sitll no results.
Here is what look the script to compile the cobol :
call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\vcvarsamd64.bat"
set COB_CONFIG_DIR=C:\OpenCobol\config
set COB_COPY_DIR=C:\OpenCobol\Copy
set COB_LIBS=%COB_LIBS% c:\OpenCobol\libpq.lib
set COB_LIBRARY_PATH=C:\OpenCobol\bin
set COB_PRE_LOAD=C:\OpenCobol\libpq.dll
#echo on
cobc -info
cobc -free -o pgcob -L:"C:\OpenCobol" -llibpq.lib test_cobol\postgres.cob
call cobcrun pgcob
I don't see anything missing, I'm using the 64-bit binaries from kiska's site and use the 64-bit cl.exe from Visual Studio, Postgres is a 64 bit version too (checked with dependencyChecker).
I even tryed to compile the generated C from Visual Studio, same result, but I may miss something, I'm pretty rotten in C and never really had to manage DLL or use Visual Studio.
What am I missing ?
COB_PRE_LOAD doesn't take any path or extension, see the short documentation for the available runtime configurations. I guess
set COB_LIBRARY_PATH=C:\OpenCobol\bin;C:\OpenCobol
set COB_PRE_LOAD=libpq
Will work. You can omit the C:\OpenCobol\bin if you did not placed any additional executables there.
If it doesn't work (even if it does) I'd try to get the C functions resolved at compile time. Either use
CALL STATIC "PQconnectdb" using ...
or an appropriate CALL-CONVENTION or leave the program as-is and use
cobc -free -o pgcob -L"C:\OpenCobol" -llibpq -K PQconnectdb test_cobol\postgres.cob
From cobc --help:
-K generate CALL to <entry> as static
In general: the binaries from kiska.net are quite outdated. I highly suggest getting newer ones from the official download site or ideally build them on your own from source, see the documentation for building GnuCOBOL with VisualStudio.

How to get Resharpers InspectCode to recognize Plugins?

I am trying to run ReSharpers command line tool InspectCode.exe. It's running fine doing it's job with the expected output.
However after my earlier attempt to get plugins to work, this time with the new version it is supposed to be supported. There is a switch in the command line interface that allows to specify the extension you want to use.
/extensions (/x) – allows using ReSharper extensions that affect code analysis. To use an extension, specify its ID, which you can find by opening the extension package page in the ReSharper Gallery, and then the Package Statistics page. Multiple values are separated with the semicolon.
But I cannot get it to work properly. I cannot even provoke any reaction to the /x switch at all. No matter how or what I pass, I get no feedback from the executable and the output is identical. I don't even get an error message when passing obvious garbage.
I tried the following commandlines for the exact same result:
inspectcode.exe /o="rcli.xml" /swea /x="ReSharper.StyleCop" "my.sln"
inspectcode.exe /o="rcli.xml" /swea /x=ReSharper.StyleCop "my.sln"
inspectcode.exe /o="rcli.xml" /swea "my.sln"
inspectcode.exe /o="rcli.xml" /swea /x=ABCDEFG "my.sln"
Result
JetBrains Inspect Code 9.1.1
Running in 64-bit mode, .NET runtime 4.0.30319.18444 under Microsoft Windows NT
6.1.7601 Service Pack 1
Enabled solution-wide analysis according to Inspect Code command line Setting.
Analyzing files
[files]
Inspection report was written to rcli.xml
What am I doing wrong? How to get extensions to work?
I already tried the R# forums, but it took them more then 24h to approve my post and so far I'm not sure someone else even read it.
Unfortunately, the support for extensions was dropped in 9.0 due to the refactorings in the "ReSharper platform". I hope that JetBrains will bring it back soon.
See RSRP-436208.
This is a late answer that might help future readers (like myself). Currently inspectcode.exe will automatically look for and use any NuGet packages that are in the same folder as the executable (source).
Example for CleanCode extension:
if you have a R# instance on some machine and install the extension, it will be placed in C:\Users\{user}\AppData\Local\JetBrains\plugins\MO.CleanCode.5.6.15
copy MO.CleanCode.5.6.15.nupkg and paste it next to inspectcode.exe
when running inspectcode with verbosity = VERBOSE, the extension should appear in the Zones list:
$cmd = "..\JetBrains.ReSharper.CommandLineTools.2019.3.4\inspectcode.exe"
$outputFile = "..\Output\$($outputName).xml"
& $cmd -o="$outputFile" $sln --verbosity=VERBOSE
Zones: (52pcs)[CodeInspectionPageImplZone, DaemonEngineZone,
DaemonZone, IAmd64CpuArchitectureHostZone, IAspMvcZone,
IBatchToolEnvironmentZone, IClrImplementationHost Zone,
IClrPsiLanguageZone, ICodeEditingOptionsPageImplZone,
IConsoleEnvironmentZone, ICppProductZone, ICpuArchitectureHostZone,
IDocumentModelZone, IEnvironmentZone, IHostSolutionZone,
IInspectCodeConsoleEnvironmentZone, IInspectCodeEnvironmentZone,
IInspectCodeZone, ILanguageAspZone, ILanguageBuildScriptsZone,
ILanguageCppZone, I LanguageCSharpZone, ILanguageCssZone,
ILanguageHtmlZone, ILanguageIlZone, ILanguageJavaScriptZone,
ILanguageMsBuildZone, ILanguageNAntZone, ILanguageProtobufZone, ILa
nguageRazorZone, ILanguageRegExpZone, ILanguageResxZone,
ILanguageVBZone, ILanguageXamlZone, INetFrameworkHostZone, INuGetZone,
IOperatingSystemHostZone, IProjectMode lZone,
IPsiAssemblyFileLoaderImplZone, IPsiLanguageZone,
IPublicVisibilityZone, IRdFrameworkZone, IRiderModelZone,
ISinceClr2HostZone, ISinceClr4HostZone, ITextContro lsZone,
IToolsOptionsPageImplZone, IWebPsiLanguageZone, IWindowsNtHostZone,
PsiFeaturesImplZone, ReplaceableByIntelliJPlatformZone, SweaZone]
Packages: (23pcs)[JetBrains.ExternalAnnotations,
JetBrains.Platform.Core.Ide, JetBrains.Platform.Core.IisExpress,
JetBrains.Platform.Core.MsBuild, JetBrains.Platform. Core.Shell,
JetBrains.Platform.Core.Text, JetBrains.Platform.Interop.CommandLine,
JetBrains.Platform.Interop.dotMemoryUnit.Framework,
JetBrains.Platform.Interop.dotMe moryUnit.Interop.Console,
JetBrains.Platform.Interop.dotMemoryUnit.Interop.Ide,
JetBrains.Platform.RdProtocol, JetBrains.Psi.Features.Core,
JetBrains.Psi.Features.Cpp .Src.Core, JetBrains.Psi.Features.src,
JetBrains.Psi.Features.Tasks, JetBrains.Psi.Features.UnitTesting,
JetBrains.Psi.Features.Web.Core, JetBrains.ReSharperAutomatio
nTools.src.CleanupCode,
JetBrains.ReSharperAutomationTools.src.CommandLineCore,
JetBrains.ReSharperAutomationTools.src.CommandLineProducts,
JetBrains.ReSharperAutomat ionTools.src.DuplicatesFinder,
JetBrains.ReSharperAutomationTools.src.InspectCode, MO.CleanCode]

Bare minimum plugin won't work on moodle

I'm getting myself used to moodle programming. I used this guide to make it, but it's from 2010. It might be old, so I'm not sure if it's any good.
This is the error moodle gives me:
Debug info: Missing mandatory en language pack.
Error code: detectedbrokenplugin
Stack trace:
line 634 of \lib\upgradelib.php: plugin_defective_exception thrown
line 420 of \lib\upgradelib.php: call to upgrade_plugins_modules()
line 1626 of \lib\upgradelib.php: call to upgrade_plugins()
line 434 of \admin\index.php: call to upgrade_noncore()
I do have a language pack in my /pluginname/lang/en_US.php.
You can find the plugin HERE.
The structure is /pluginname/lang/en/plugintype_pluginname.php
The en folder is mandatory which is generally British English.
You can add a US folder too /pluginname/lang/en_us/plugintype_pluginname.php
plugintype is mod, block, local, etc.

threads error in running stanford LLDA tmt scala models

when I run stanford LLDA tmt scala models, I encounter a few problems. One of them is a thread error when I try to do inference with LLDA tmt model. The code I am running is exactly the one provided by Shreyas Karnik in the sourceforge link,
#Skarab: Here are the links to the code which I used to bit.ly/ocK2T9 (learning) and bit.ly/qIWb6C (inference) please let me know if you still encounter any errors.
The error message is,
Command started: Fri Jun 21 21:34:48 CDT 2013
java -Dscalanlp.distributed.hub=socket://crick7.mayo.edu:41080/hub -Dscalanlp.distributed.id=/tmt/0 -Xmx100000m edu.stanford.nlp.tmt.TMTMain "/data4/bsi/nlp/s110067.sharp/bioask/tmtModels/example-7-llda-infer.scala"
Loading model ...
TSVFile("test.csv") ~> IDColumn(1) ~> Column(2) ~> TokenizeWith(SimpleEnglishTokenizer.V1() ~> CaseFolder() ~> WordsAndNumbersOnlyFilter() ~> MinimumLengthFilter(3))
Generating output ...
[Concurrent] 128 permits
[Concurrent] 128 permits
Exception in thread "Thread-3" java.lang.IndexOutOfBoundsException: 1
at scala.collection.LinearSeqOptimized$class.apply(LinearSeqOptimized.scala:51)
at scala.collection.immutable.List.apply(List.scala:45)
at scalanlp.stage.Column.map(ColumnSelectors.scala:51)
at scalanlp.stage.Column.map(ColumnSelectors.scala:46)
at scalanlp.stage.generic.Mapper$$anonfun$apply$1$$anonfun$apply$2.apply(Mapper.scala:36)
at scalanlp.stage.Item.map(Item.scala:32)
at scalanlp.stage.generic.Mapper$$anonfun$apply$1.apply(Mapper.scala:36)
at scalanlp.stage.generic.Mapper$$anonfun$apply$1.apply(Mapper.scala:36)
at scala.collection.Iterator$$anon$19.next(Iterator.scala:335)
at scala.collection.Iterator$$anon$19.next(Iterator.scala:335)
at edu.stanford.nlp.tmt.data.concurrent.Concurrent$$anonfun$map$2.apply(Concurrent.scala:96)
at edu.stanford.nlp.tmt.data.concurrent.Concurrent$$anonfun$map$2.apply(Concurrent.scala:88)
at edu.stanford.nlp.tmt.data.concurrent.Concurrent$$anon$4.run(Concurrent.scala:45)
Would you give help? highly appreciate it!
This is a known issue of tmt-0.4.0 for many users. tmt-0.2.1 works just fine.
But the support for tmt-0.4.0 has been discontinued and for tmt-0.2.1 even before that.
You can check out http://mallet.cs.umass.edu/, which also has easy to start GUIs available such as http://www.themacroscope.org/?page_id=391.
Check any .csv files for DOS/Unix incompatibility.
My experience may be relevant:
I was also getting the error java.lang.IndexOutOfBoundsException, when running tmt-0.4.0 from a command line on Windows. My workflow had a python program splitting my data set into training and test .csv files. But they were written in DOS mode. See for example,
http://www.cs.toronto.edu/~krueger/csc209h/tut/line-endings.html
A confirmation of this is that when opening them in Excel, there was an extra line, and when opening them in Emacs, there's a telltale ^M.
I ran dos2unix on the .csv files, and then the TMT Scala programs worked.

Errors with installing SNA packages

I've been trying to install SNA packages but i always get the next errors,
> install.packages("sna")
Installing package(s) into ‘/home/rvaca/R/i486-pc-linux-gnu-library/2.14’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Loading Tcl/Tk interface ... done
trying URL 'http://cran.cnr.Berkeley.edu/src/contrib/sna_2.2-0.tar.gz'
Content type 'application/x-gzip' length 273329 bytes (266 Kb)
opened URL
==================================================
downloaded 266 Kb
The downloaded packages are in
‘/tmp/Rtmp7iF3Qz/downloaded_packages’
> library(sna)
starting httpd help server ... done
Error in attr(helpObj, "call") <- this.call :
attempt to set an attribute on NULL
Error: package/namespace load failed for ‘sna’
> library("sna")
Error in attr(helpObj, "call") <- this.call :
attempt to set an attribute on NULL
Error: package/namespace load failed for ‘sna’
> library('sna')
Error in attr(helpObj, "call") <- this.call :
attempt to set an attribute on NULL
Error: package/namespace load failed for ‘sna’
What happened? Thanks in advance
vacing
When loading the sna package using library(sna) or require(sna), the function .First.lib() is (still) called. This function is now among the defunct functions in the base package (see ?.First.lib), but that's beside the point.
Looking at the source files for sna, .First.lib() is defined in the file zzz.R and contains the line
ehelp <- help(package="sna")$info[[1]].
This does not work well if getOption("help_type") is not "text". You could, therefore, try setting this option before loading the package to see if that works.
options(help_type="text")
library(sna)
Does this still produce an error?
EDIT
Since the above still gives an error, and since the package has properties that are being phased out (i.e., no namespace, and using .First.lib()), I would recommend contacting the package's maintainer (perhaps with a reference to this question on SO):
packageDescription("sna")$Maintainer
Again, my suspicion is that the problem lies in creating the object ehelp in the .First.lib() function, which is called since there is no package namespace specified.
Ok this is the result of sessionInfo(), (I forgot to comment that i runs it into Eclipse)
> sessionInfo()
R version 2.14.2 (2012-02-29)
Platform: i486-pc-linux-gnu (32-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=en_US.UTF-8
[9] LC_ADDRESS=en_US.UTF-8 LC_TELEPHONE=en_US.UTF-8
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] Cairo_1.5-1 igraph_0.5.5-4 rj_1.0.3-7
loaded via a namespace (and not attached):
[1] rj.gd_1.0.3-3 sna_2.2-0 tools_2.14.2