Skip to content

Instantly share code, notes, and snippets.

@michimau
Last active October 31, 2024 01:41
Show Gist options
  • Save michimau/6dc23c8ad5604f46814426de7c0b170c to your computer and use it in GitHub Desktop.
Save michimau/6dc23c8ad5604f46814426de7c0b170c to your computer and use it in GitHub Desktop.
#!/bin/bash
SERVICEURL=http://localhost:8001
USERNAME=admin
PASSWORD=changemeXX
COOKIE_FILE=cookie.txt
function getCSFR {
CSRF=`curl -s -u $USERNAME:$PASSWORD -c $COOKIE_FILE -X GET $SERVICEURL/apps/forms | grep data-requesttoken | cut -d '"' -f6`
}
function newForm {
getCSFR
POST_RESULT=`curl -s -b $COOKIE_FILE --user $USERNAME:$PASSWORD -X POST -H "Content-Type: application/json; charset=utf-8" \
-H "requesttoken: $CSRF" $SERVICEURL/ocs/v2.php/apps/forms/api/v1/form`
FORM_ID=`echo $POST_RESULT | jq -r '.id'`
echo $POST_RESULT
}
function update {
#args: objecttype object_id key pair
getCSFR
POST_RESULT=`curl -s -b $COOKIE_FILE --user $USERNAME:$PASSWORD -X POST -H "Content-Type: application/json; charset=utf-8" -H "requesttoken: $CSRF" \
--data '{"id": '$2', "keyValuePairs": {"'"$3"'": "'"$4"'"}}' $SERVICEURL/ocs/v2.php/apps/forms/api/v1/$1/update`
echo $POST_RESULT
}
function newQuestion {
getCSFR
POST_RESULT=`curl -s -b $COOKIE_FILE --user $USERNAME:$PASSWORD -X POST -H "Content-Type: application/json; charset=utf-8" \
-H "requesttoken: $CSRF" --data '{"formId": '$1', "type":"'"$2"'", "text": "'"$3"'"}' $SERVICEURL/ocs/v2.php/apps/forms/api/v1/question`
QUESTION_ID=`echo $POST_RESULT | jq -r '.id'`
echo $POST_RESULT
}
function newOption {
getCSFR
POST_RESULT=`curl -s -b $COOKIE_FILE --user $USERNAME:$PASSWORD -X POST -H "Content-Type: application/json; charset=utf-8" \
-H "requesttoken: $CSRF" --data '{"questionId": '$1', "text":"'"$2"'"}' $SERVICEURL/ocs/v2.php/apps/forms/api/v1/option`
echo $POST_RESULT
}
newForm
update form $FORM_ID "title" "Translation Quality Monitoring"
update form $FORM_ID "description" "This is the description"
newQuestion $FORM_ID multiple_unique "Please assign a quality score"
update question $QUESTION_ID "mandatory" 1
newOption $QUESTION_ID "5 - Perfect translateion, no editing necessary"
newOption $QUESTION_ID "4 - Excellent translation (max two edits per page to improve style or make the translation read better)"
newOption $QUESTION_ID "3 - Translation is good in general, but you had to edit more than two times per page"
newOption $QUESTION_ID "2 - Original meaning of the text has not been rendered preciselly enough. \nReadability is slightly affected due to inaccuracy OR more than 2 spelling mistakes."
newOption $QUESTION_ID "1 - Mistranslation(s) occured and the original meaning was distorted in the translation. \nRequires extra effort from the reader to understand the intended meaning, but do not make it impossible"
newOption $QUESTION_ID "0 - Text doesn't make any sens/mistranslation or spelling mistakes resulting in change in meaning of the text/it sounds unintelligible."
newQuestion $FORM_ID multiple "What kind of mistaked did you find? (multiple choices)"
newOption $QUESTION_ID "a - Inaccurate translation."
newOption $QUESTION_ID "b - Mistranslation (meaning changed from the original)."
newOption $QUESTION_ID "c - Not the right terms were used."
newOption $QUESTION_ID "d - The text didn't read well, it seemed unnatural."
newOption $QUESTION_ID "e - Spelling mistakes"
#newOption $QUESTION_ID "f - The text didn't read well, it seemed unnatural."
newQuestion $FORM_ID long "If a term was wrongly translated or you recomment to use different one, please list below the affected terms (separated by comma)"
rm $COOKIE_FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment