Hints can something else than text
This commit is contained in:
parent
8c2e8a19d1
commit
b772a22705
6 changed files with 69 additions and 25 deletions
|
@ -59,8 +59,12 @@ new_hint() {
|
|||
TITLE=`echo "$3" | sed 's/"/\\\\"/g'`
|
||||
CONTENT=`echo "$4" | sed 's/"/\\\\"/g' | sed ':a;N;$!ba;s/\n/<br>/g'`
|
||||
COST="$5"
|
||||
URI="$6"
|
||||
|
||||
curl -f -s -d "{\"title\": \"$TITLE\", \"content\": \"$CONTENT\", \"cost\": $COST}" "${BASEURL}/api/themes/$THEME/exercices/$EXERCICE/hints" |
|
||||
[ -n "${CONTENT}" ] && CONTENT=", \"content\": \"${CONTENT}\""
|
||||
[ -n "${URI}" ] && URI=", \"path\": \"${BASEFILE}${URI}\""
|
||||
|
||||
curl -f -s -d "{\"title\": \"$TITLE\"$CONTENT$URI, \"cost\": $COST}" "${BASEURL}/api/themes/$THEME/exercices/$EXERCICE/hints" |
|
||||
grep -Eo '"id":[0-9]+,' | grep -Eo "[0-9]+"
|
||||
}
|
||||
|
||||
|
@ -191,15 +195,28 @@ do
|
|||
|
||||
|
||||
# Hints
|
||||
EXO_HINT=$(get_file "${THM_BASEURI}${EXO_BASEURI}/hint.txt")
|
||||
if [ -n "$EXO_HINT" ]; then
|
||||
HINT_ID=`new_hint "${THEME_ID}" "${EXO_ID}" "Astuce #1" "${EXO_HINT}" "${HINT_COST}"`
|
||||
if [ -z "$HINT_ID" ]; then
|
||||
echo -e "\e[31;01m!!! An error occured during hint import!\e[00m (title=Astuce #1;content=${EXO_HINT};cost=${HINT_COST})"
|
||||
else
|
||||
echo -e "\e[32m>>> New hint added:\e[00m $HINT_ID - Astuce #1"
|
||||
HINTS=$(get_dir "${THM_BASEURI}${EXO_BASEURI}/hints/" | sed -E 's#(.*)#hints/\1#')
|
||||
[ -z "${HINTS}" ] && HINTS=$(get_dir "${THM_BASEURI}${EXO_BASEURI}/" | grep ^hint.)
|
||||
[ -z "${HINTS}" ] && HINTS="hint.txt"
|
||||
HINT_COUNT=1
|
||||
echo "${HINTS}" | while read HINT
|
||||
do
|
||||
EXO_HINT=$(get_file "${THM_BASEURI}${EXO_BASEURI}/${HINT}")
|
||||
if [ -n "$EXO_HINT" ]; then
|
||||
if echo "${EXO_HINT}" | file --mime-type -b - | grep text/ && [ $(echo "${EXO_HINT}" | wc -l) -lt 25 ]; then
|
||||
HINT_ID=`new_hint "${THEME_ID}" "${EXO_ID}" "Astuce #${HINT_COUNT}" "${EXO_HINT}" "${HINT_COST}"`
|
||||
else
|
||||
HINT_ID=`new_hint "${THEME_ID}" "${EXO_ID}" "Astuce #${HINT_COUNT}" "" "${HINT_COST}" "${THM_BASEURI}${EXO_BASEURI}/${HINT}"`
|
||||
fi
|
||||
|
||||
if [ -z "$HINT_ID" ]; then
|
||||
echo -e "\e[31;01m!!! An error occured during hint import!\e[00m (title=Astuce #${HINT_COUNT};content=${EXO_HINT};cost=${HINT_COST})"
|
||||
else
|
||||
echo -e "\e[32m>>> New hint added:\e[00m $HINT_ID - Astuce #${HINT_COUNT}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
HINT_COUNT=$(($HINT_COUNT + 1))
|
||||
done
|
||||
|
||||
|
||||
# Files: splited
|
||||
|
|
Reference in a new issue