API for Candidate Group Management¶
When use OnlineExamMaker, we provide API for users to achieve data synchronization, here are the interfaces for organization management below.
Synchronizing the datum of candidates can conveniently exchange the candidates' datum between the system, and avoid the error that may appear manually. Automatic synchronization is timely and quick, which can synchronize the information of the candidates and the organizations they belong to.
Note: OnlineExamMaker API is only available for Premium users, if you want to request data from OnlineExamMaker API, please upgrade your account to Premium member.
Candidate group management¶
OnlineExamMaker allows exam organizers manage students, employees, learners in groups, you can create, delete, or rename a goup directly. OnlineExamMaker supports unlimited-level tree-like groupc management, you can create sub-group like the image below.
1. Add a candidate group¶
Add a candidate group:¶
POST https://api.onlineexammaker.com/api/v1/student/addcategory
Parameter:¶
code=authorization code&time=current timestamp
Parameter description:¶
-
code: Verification code is unique to each OnlineExamMaker account, Premium users can get it in "System Settings" -> "API & SSO Settings" in OnlineExamMaker dashoboard. (Related tutorial: How to get verification code for API?)
-
time: Current timestamp, for example: 1638768935.
-
parentGid: Parent node id. If the value is 0, it means inserting the root node.
-
title: The name of the new created group.
-
Authorization: Please put Token in the request header, you can view the sample code for details. In simple terms: we concatenate the current timestamp and your code, and encrypt them with MD5.
If the operation is successful, the return value is:¶
{
"gid":2995, //The id of new group that are created successfully
"status":"ok"
}
If the operation fails, the return value is:¶
Interface usage examples:¶
package main
import (
"crypto/md5"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"time"
)
const (
Code = "xxx"
)
func main() {
host := "https://api.onlineexammaker.com"
resource := "/api/v1/student/addcategory"
client := &http.Client{}
fullPath := host + resource
time64 := time.Now().UTC().Unix()
data := make(url.Values)
data["code"] = []string{Code}
data["parentGid"] = []string{"0"}
data["title"] = []string{"newgroup"}
data["time"] = []string{strconv.Itoa(int(time64))}
req, _ := http.NewRequest(http.MethodPost, fullPath, strings.NewReader(data.Encode()))
ParseToken := fmt.Sprintf("%x", md5.Sum([]byte(strconv.FormatInt(time64, 10)+Code)))
req.Header.Set("Authorization", ParseToken)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
resp, err := client.Do(req)
if err != nil {
log.Println(err)
return
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Println(err)
return
}
fmt.Println(string(b))
f, _ := os.OpenFile("test.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
f.Write(b)
}
2. Edit group name¶
Edit group name:¶
POST https://api.onlineexammaker.com/api/v1/student/renamegroup
Parameter:¶
code=authorization code&time=current timestamp
Parameter description:¶
-
code: Verification code is unique to each OnlineExamMaker account, Premium users can get it in "System Settings" -> "API & SSO Settings" in OnlineExamMaker dashoboard. (Related tutorial: How to get verification code for API?)
-
time: Current timestamp, for example: 1638768935.
-
gid: The id of the group that are modified.
-
title: New group name.
-
Authorization: Please put Token in the request header, you can view the sample code for details. In simple terms: we concatenate the current timestamp and your code, and encrypt them with MD5.
If the operation is successful, the return value is:¶
{
"gid":2995,
"oldTitle":"newgroup", //Old group name
"status":"ok"
}
If the operation fails, the return value is:¶
Interface usage examples:¶
package main
import (
"crypto/md5"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"time"
)
const (
Code = "xxx"
)
func main() {
host := "https://api.onlineexammaker.com"
resource := "/api/v1/student/renamegroup"
client := &http.Client{}
fullPath := host + resource
time64 := time.Now().UTC().Unix()
data := make(url.Values)
data["code"] = []string{Code}
data["gid"] = []string{"2995"}
data["title"] = []string{"newgroupname"}
data["time"] = []string{strconv.Itoa(int(time64))}
req, _ := http.NewRequest(http.MethodPost, fullPath, strings.NewReader(data.Encode()))
ParseToken := fmt.Sprintf("%x", md5.Sum([]byte(strconv.FormatInt(time64, 10)+Code)))
req.Header.Set("Authorization", ParseToken)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
resp, err := client.Do(req)
if err != nil {
log.Println(err)
return
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Println(err)
return
}
fmt.Println(string(b))
f, _ := os.OpenFile("test.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
f.Write(b)
}
3. Delete a candidate group¶
Delete a candidate group:¶
POST https://api.onlineexammaker.com/api/v1/student/delGroup
Parameter:¶
code=authorization code&time=current timestamp
Parameter description:¶
-
code: Verification code is unique to each OnlineExamMaker account, Premium users can get it in "System Settings" -> "API & SSO Settings" in OnlineExamMaker dashoboard. (Related tutorial: How to get verification code for API?)
-
time: Current timestamp, for example: 1638768935.
-
gid: The id of the group that is deleted.
-
Authorization: Please put Token in the request header, you can view the sample code for details. In simple terms: we concatenate the current timestamp and your code, and encrypt them with MD5.
If the operation is successful, the return value is:¶
{
"status":"ok"
}
If the operation fails, the return value is:¶
Interface usage examples:¶
package main
import (
"crypto/md5"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"time"
)
const (
Code = "xxx"
)
func main() {
host := "https://api.onlineexammaker.com"
resource := "/api/v1/student/delGroup"
client := &http.Client{}
fullPath := host + resource
time64 := time.Now().UTC().Unix()
data := make(url.Values)
data["code"] = []string{Code}
data["gid"] = []string{"2996"}
data["time"] = []string{strconv.Itoa(int(time64))}
req, _ := http.NewRequest(http.MethodPost, fullPath, strings.NewReader(data.Encode()))
ParseToken := fmt.Sprintf("%x", md5.Sum([]byte(strconv.FormatInt(time64, 10)+Code)))
req.Header.Set("Authorization", ParseToken)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
resp, err := client.Do(req)
if err != nil {
log.Println(err)
return
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Println(err)
return
}
fmt.Println(string(b))
f, _ := os.OpenFile("test.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
f.Write(b)
}
4. Move a candidate group¶
Move a candidate group:¶
POST https://api.onlineexammaker.com/api/v1/student/mvgroup
Parameter:¶
code=authorization code&time=current timestamp
Parameter description:¶
-
code: Verification code is unique to each OnlineExamMaker account, Premium users can get it in "System Settings" -> "API & SSO Settings" in OnlineExamMaker dashoboard. (Related tutorial: How to get verification code for API?)
-
time: Current timestamp, for example: 1638768935.
-
gid: The id of the group that is moved.
-
mvToGid: The id of the targeted group.
-
Authorization: Please put Token in the request header, you can view the sample code for details. In simple terms: we concatenate the current timestamp and your code, and encrypt them with MD5.
If the operation is successful, the return value is:¶
{
"status":"ok"
}
If the operation fails, the return value is:¶
Interface usage examples:¶
package main
import (
"crypto/md5"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"time"
)
const (
Code = "xxx"
)
func main() {
host := "https://api.onlineexammaker.com"
resource := "/api/v1/student/mvgroup"
client := &http.Client{}
fullPath := host + resource
time64 := time.Now().UTC().Unix()
data := make(url.Values)
data["code"] = []string{Code}
data["gid"] = []string{"2996"}
data["mvToGid"] = []string{"2995"}
data["time"] = []string{strconv.Itoa(int(time64))}
req, _ := http.NewRequest(http.MethodPost, fullPath, strings.NewReader(data.Encode()))
ParseToken := fmt.Sprintf("%x", md5.Sum([]byte(strconv.FormatInt(time64, 10)+Code)))
req.Header.Set("Authorization", ParseToken)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
resp, err := client.Do(req)
if err != nil {
log.Println(err)
return
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Println(err)
return
}
fmt.Println(string(b))
f, _ := os.OpenFile("test.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
f.Write(b)
}
5. Get group list¶
Get group list:¶
GET https://api.onlineexammaker.com/api/v1/student/lsgroups?code=authorization code&time=current timestamp
Parameter:¶
code=authorization code&time=current timestamp
Parameter description:¶
-
code: Verification code is unique to each OnlineExamMaker account, Premium users can get it in "System Settings" -> "API & SSO Settings" in OnlineExamMaker dashoboard. (Related tutorial: How to get verification code for API?)
-
time: Current timestamp, for example: 1638768935.
-
gid(Optional): Query the subgroups under the current group. If you want to query all groups, you do not need to pass this value.
-
Authorization: Please put Token in the request header, you can view the sample code for details. In simple terms: we concatenate the current timestamp and your code, and encrypt them with MD5.
If the operation is successful, the return value is:¶
{
"data":[
{
"gid":2989,
"title":"2989 group name"
},
{
"gid":2987,
"title":"2987 group name"
}
],
"status":"ok"
}
//Note: The returned group list is the subgroups of the current group, excluding grandchildren. If there are no students in a group, it will not appear in the group list.
If the operation fails, the return value is:¶
Interface usage examples:¶
package main
import (
"crypto/md5"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"strconv"
"time"
)
const (
Code = "xxx"
)
func main() {
host := "https://api.onlineexammaker.com"
resource := "/api/v1/student/lsgroups"
client := &http.Client{}
fullPath := host + resource
req, _ := http.NewRequest(http.MethodGet, fullPath, nil)
time64 := time.Now().UTC().Unix()
ParseToken := fmt.Sprintf("%x", md5.Sum([]byte(strconv.FormatInt(time64, 10)+Code)))
req.Header.Set("Authorization", ParseToken)
q := req.URL.Query()
q.Add("code", Code)
q.Add("gid", "2988")
q.Add("time", strconv.Itoa(int(time64)))
req.URL.RawQuery = q.Encode()
resp, err := client.Do(req)
if err != nil {
log.Println(err)
return
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Println(err)
return
}
// fmt.Println(string(b))
f, _ := os.OpenFile("test.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
f.Write(b)
}